package com.lglin.dao.product;

import com.lglin.bean.product.entity.Category;
import com.lglin.bean.product.entity.Product;
import com.lglin.common.bean.Picture;
import com.lglin.common.bean.Review;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ProductDao {

    @Select("select * from category")
    List<Category> getCategory();

    int getCountBycId(@Param("cid") int cId, @Param("key") String key);

    List<Integer> selectBycId(@Param("cIds") int[] cIds);

    List<Product> selectById(@Param("ids") List<Integer> ids,@Param("sort_flag")int sort_flag, @Param("key") String key);

    List<Product> selectAll(@Param("sort_flag") int sort_flag, @Param("key") String key);

    @Select("select * from picture where pid = #{pid}")
    List<Picture> getPicturesById(int pid);


    List<Review> getReviewsById(int pid);

    Product selectOneById(int id);

    @Select("select count(*) from review where pid=#{id}")
    int getReviewsCountById(int id);

    @Select("select star from review where pid=#{id}")
    List<Integer> getAllStarById(int id);

    List<Map<String, Object>> recomProduct(int num);
}
